package day020;

import java.io.FileOutputStream;
import java.io.IOException;
import java.io.ObjectOutputStream;
import java.util.ArrayList;

public class ObjectOutputStreamDemo2 {
    public static void main(String[] args) throws IOException {
        ObjectOutputStream oos = new ObjectOutputStream(new FileOutputStream("D:\\day020\\userList.txt"));
        User user1 = new User();
        user1.setUserName("itheima");
        user1.setPassword("123456");

        User user2 = new User();
        user2.setUserName("admin");
        user2.setPassword("654321");

        ArrayList<User> userList = new ArrayList<>();
        userList.add(user1);
        userList.add(user2);

        oos.writeObject(userList);
        oos.close();
    }
}
